﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;
using Mt.Site;
using Mt.Site.Core.Authorization;

namespace Mt.Site.Core.Members.Permissions
{
    class MemberPermissionProvider: AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));
            var MemberManage = pages.CreateChildPermission(MemberPermissions.Pages_Manage_Member, L("Member"), multiTenancySides: MultiTenancySides.Tenant);
            MemberManage.CreateChildPermission(MemberPermissions.Pages_Manage_Member_Create, L("CreateMember"), multiTenancySides: MultiTenancySides.Tenant);
            MemberManage.CreateChildPermission(MemberPermissions.Pages_Manage_Member_Update, L("UpdateMember"), multiTenancySides: MultiTenancySides.Tenant);
            MemberManage.CreateChildPermission(MemberPermissions.Pages_Manage_Member_Delete, L("DeleteMember"), multiTenancySides: MultiTenancySides.Tenant);
            MemberManage.CreateChildPermission(MemberPermissions.Pages_Manage_Member_Query, L("QueryMember"), multiTenancySides: MultiTenancySides.Tenant);

            MemberManage.CreateChildPermission(MemberPermissions.Pages_Manage_Member_ExportOut, L("ExportOutMember"), multiTenancySides: MultiTenancySides.Tenant);

        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, MtSiteConsts.LocalizationSourceName_Permissions);
        }
    }
}
